package com.suixinsanren.design.responsibilitychain.demo01;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class StNameCheck extends AbsCheckStudent {

    //获取学生名称不符合条件的学生对象
    @Override
    public List<Student> checkStudent(List<Student> studentList) {
        List<Student> stNameIsNotOk = studentList.stream().filter(stu -> {
            String stName = stu.getStName();
            return Objects.isNull(stName) || "".equals(stName);
        }).collect(Collectors.toList());
        System.out.println("名字校验不通过的数据有: " + stNameIsNotOk);
        studentList.removeAll(stNameIsNotOk);
        System.out.println("名字校验通过的数据有: " + studentList);
        return studentList;
    }
}
